package com.server.server.message.enums;

import lombok.Getter;

/**
 * @Description: This is a sample class.
 * @Author: Simon
 */
public enum SerializeAlgorithm {

    JDK((byte)0),
    JSON((byte)1),
    //default
    HESSIAN((byte) 2);

    @Getter
    private final byte type;

    SerializeAlgorithm(byte type) {
        this.type = type;
    }

    public static SerializeAlgorithm parseByName(String typeName) {
        for (SerializeAlgorithm typeEnum : SerializeAlgorithm.values()) {
            if (typeEnum.name().equalsIgnoreCase(typeName)) {
                return typeEnum;
            }
        }
        //default
        return HESSIAN;
    }

    public static SerializeAlgorithm parseByType(byte type) {
        for(SerializeAlgorithm typeEnum: SerializeAlgorithm.values()) {
            if(typeEnum.getType()==type){
                return typeEnum;
            }
        }
        return HESSIAN;
    }
}
